<?php
namespace App\Model;

use PhalApi\Model\NotORMModel as NotORM;

class ELEVENACTIVITY extends NotORM
{

    protected function getTableName($id)
    {
        return 'eleven_activity';
    }

    public function getIco()
    {
        $data = $this->getORM()->group('ico')->fetchAll();
        return $data;
    }

    public function getAll()
    {
        $data = $this->getORM()->fetchAll();
        return $data;
    }

    public function getNew()
    {
        $data = $this->getORM()->where(['level' => 0])->select('id, ico, icon, ico_icon, level, price, unit, num, start_time, end_time, send, multiple')->fetchAll();
        return $data;
    }

    public function getList($level)
    {
        $data = $this->getORM()
            ->where('level <= ?', $level)
            ->where('level != 0')
            ->select('id, ico, icon, ico_icon, price, level, unit, num, start_time, end_time, send, multiple')
            ->order('start_time asc')
            ->fetchAll();
        return $data;
    }

    public function getById($id)
    {
        $data = $this->getORM()->where(['id' => $id])->fetchOne();
        return $data;
    }

    public function getByIds($id)
    {
        $data = $this->getORM()->where("id in $id")
            ->select('id, ico, icon, ico_icon, price, unit, num, start_time, end_time, send')
            ->order('start_time asc')
            ->fetchAll();
        return $data;
    }


}